package com.hxit.sportem.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    //1.配置文档的基本信息
    //2.配置生成规则


    @Bean
    public Docket getDocket(){
        //创建封面信息对象
        ApiInfoBuilder apiInfoBuilder=new ApiInfoBuilder();
        apiInfoBuilder.title("《运动器材管理》后端接口说明文档")
                .description("此文档详细说明了运动器材管理系统项目后端接口规范.....")
                .version("v1.0.0");

        ApiInfo apiInfo=apiInfoBuilder.build();

        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.hxit.sportem.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

}
